﻿Public Class clsProdInfo
    Public Function updateTuoMo(id As String, oper As String) As Integer
        Dim szSql As String = String.Empty
        Dim rtn As Integer
        DBacs.BeginTransaction()
        Try
            szSql &= "select * from agv.tmj where task_step_id =  ?  "
            Dim dtrta As DataTable = DBacs.ExecuteSql(szSql, -1, id)
            '变更制品的状态信息（脱模时间，脱模作业员)
            szSql = String.Empty
            szSql &= "update sf.b_prod_info set update_time=(SELECT CURRENT_TIMESTAMP(6)),"
            szSql &= " status=?,tuo_mo_dt =(SELECT CURRENT_TIMESTAMP(6)),out_vu_ope = ?"
            szSql &= " where factory_id = ? and prod_id = ?"
            rtn = DBacs.ExecuteUpdateSql(szSql, -1, "7", oper, "TS", dtrta.Rows(0)("prod_id").ToString())
            szSql = String.Empty
            szSql &= "select * from sf.b_prod_info where factory_id = ? and prod_id = ? "
            Dim dtrt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", dtrta.Rows(0)("prod_id").ToString())
            If dtrt.Rows.Count > 0 Then
                If (dtrt.Rows(0)("oper_count") - dtrt.Rows(0)("tm_finish_count")) > 0 Then
                    '更新生产计划
                    szSql = String.Empty
                    szSql &= "update sf.b_pgd_lh_details set tm_finish_count = tm_finish_count + 1 where sys_id = ? "
                    rtn = DBacs.ExecuteUpdateSql(szSql, -1, dtrt.Rows(0)("b_pgd_lh_details_sys_id").ToString())
                    szSql = String.Empty
                    szSql &= "select * from sf.b_pgd_lh_details where sys_id = ? "
                    Dim dtrtb As DataTable = DBacs.ExecuteSql(szSql, -1, dtrt.Rows(0)("b_pgd_lh_details_sys_id").ToString())
                    szSql = String.Empty
                    szSql &= "update sf.b_pgd_mes set finish_count = finish_count + 1 where sys_id = ? "
                    rtn = DBacs.ExecuteUpdateSql(szSql, -1, dtrtb.Rows(0)("b_pgd_mes_sys_id").ToString())
                End If
            End If
            DBacs.CommitTransaction()
        Catch ex As Exception
            DBacs.RollbackTransaction()
            rtn = -2
        End Try
        Return rtn
    End Function
End Class
